#include <iostream>
#include <algorithm>
using namespace std;
int N, NA, NB;
int A[205], B[205];
int PK[5][5] = {{0, 0, 1, 1, 0}, {1, 0, 0, 1, 0}, {0, 1, 0, 0, 1}, {0, 0, 1, 0, 1}, {1, 1, 0, 0, 0}};
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    cin >> N >> NA >> NB;
    for (int i = 0; i < NA; i++)
    {
        cin >> A[i];
    }
    for (int i = 0; i < NB; i++)
    {
        cin >> B[i];
    }
    int sum1 = 0, sum2 = 0;
    for (int i = 0; i < N; i++)
    {
        sum1 += PK[A[i % NA]][B[i % NB]];
        sum2 += PK[B[i % NB]][A[i % NA]];
    }
    cout << sum1 << " " << sum2 << endl;
    return 0;
}